;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; FILE:    blocks-helper.lisp
;; AUTHOR:  glen hunt
;; DESC:    helper functions for the blocksworld (cse471/598 ex4)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defparameter fmt " ~15a~a~%" "format for printing help menu")

(defun help ()
  "Displays the help menu."
  (format t "~%~%")
  (format
  t "============================================================~%")
  (format t " ICARUS.EX6 HELP~%")
  (format
  t "============================================================~%")
  (*help-commands))

(defun *help-commands ()
  "Displays Icarus commands."
  (format t " Commands~%")
  (format t "------------------------------------------------------------~%")
  (format t fmt "(ex SKILL)" "execute skill SKILL, and resets the scene.")
  (format t fmt "(ex+ SKILL)" "execute skill SKILL, but leave the scene")
  (format t fmt "" "unchanged.")
  (format t fmt "(reload)" "reload Icarus and concepts file.")
  (format t fmt "(scene S)" "loads scene S. NOTE: this will reset the")
  (format t fmt "" "scene, nullifying any changes resulting from")
  (format t fmt "" "skill execution.")
  (format t fmt "(state)" "prints the current state.")
  (format t "~%"))

(defun reload ()
  "Reload Icarus and concepts file."
  (load "./loader"))

(defun scene (s)
  "Runs a scene in Icarus."
  (eval (read-from-string (format nil "(task~a)" s)))
  (run 1))

(defun state ()
  "Print the current state."
  (cond ((boundp 'state*)
	 (pprint-state))
	(t (format t "~%~%I can't print the state yet - try loading a scene first.~%~%"))))

(defmacro ex (skill)
  "Execute a skill, and reset the scene."
  `(progn (execute-skill ,skill)))

(defmacro ex+ (skill)
  "Execute a skill, but don't reset the scene."
  `(progn (execute-skill+ ,skill)))

(defun psolve ()
  (create-problems ((on A B)
		    (on B C)
		    (on C D)
		    (on-table D T1))))
		    
(defun psolve2 ()
  (create-problems ((two-tower B C)
		    (on A  B))))

(defun psolve3 ()
  (create-problems ((two-stack A B)
		    (on B C)
		    (on-table C T1))))